{include file="common/head"/} 
<div class="admin-main">
    <fieldset class="layui-elem-field layui-field-title"><legend>订单结算单</legend></fieldset>
    <a href="{:url('settlement')}" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe857;</i>所有结算单明细</a>  
    <div class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon"></i>以下统计订单为 “已确认” 并且 “未结算” 状态的订单金额及订单数！</div> 
	<div class="layui-clear"></div> 
    <table class="layui-table layui-hide" id="orderlist" lay-filter="listss"></table>
</div>    
<script src="/static/plugins/layui/layui.js"></script> 
<script type="text/html" id="action">
    {{# if(d.state==0){ }}
        <div class="layui-btn layui-btn-normal layui-btn-xs" lay-event="passit">处理</div>
    {{# }else{ }}
        <div class="layui-btn layui-btn-disabled layui-btn-xs">已处理</div>
    {{# } }} 
</script>
<script>
    layui.use(['layer','table','form','laydate'], function() {
        var table = layui.table,form = layui.form, layer = layui.layer;
        $ = layui.jquery;
        var userid="{$userid}";
        var shopid="{$shopid}";
        tableIn = table.render({
            id: 'listss',
            elem: '#orderlist', 
            url: '{:url("settlementmin")}',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'orderid', title: '结算单号',align: 'center', width:138, fixed: true},
                {field: 'typename', title: '结算类型',align: 'center', width: 100, fixed: true},
                {field: 'money_sf', title: '收付金额',align: 'center', width: 120, fixed: true}, 
                {field: 'state_name', title: '收付状态',align: 'center', width: 100},  
                {field: 'money_a', title: '结算金额',align: 'center', width: 120}, 
                {field: 'money_s', title: '手续费',align: 'center', width: 120}, 
                {field: 'number', title: '订单数量',align: 'center', width: 100},
                {field: 'shopname', title: '码商/商户',align: 'center', width: 130},
                {field: 'username', title: '结算对象',align: 'center', width: 130},
                {field: 'mobile', title: '联系方式',align: 'center', width: 158},
                {field: 'addtime', title: '结算时间',align: 'center', width: 142},  
                {title: '操作', width: 80,align: 'center', fixed:'right',toolbar: '#action'},
            ]],
            limit: 60 //每页默认显示的数量
            ,where: {userid:userid,shopid:shopid}
        }); 
        table.on('tool(listss)', function(obj) {
            var data = obj.data;
            if(obj.event === 'passit') {
            	var type=data.type;
                tipss='您将进行款项操作，请慎重？';
                layer.confirm(tipss, function(index){ 
                    $.post("{:url('pass_jiesuan')}",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){ 
                            	tableIn.reload();
                            });
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });  
    });
    function tojiesuan(timequ){
        $.post("jieshu",{timequ:timequ}, function (res) { 
            if (res.code === 1) {
                layer.msg(res.msg, {time: 1500, icon: 1}, function () {
                     $.post("jieshu_shop",{timequ:timequ}, function (res) { 
			            if (res.code === 1) {
			                layer.msg(res.msg, {time: 1000, icon: 1}, function () {
			                	tableIn.reload();     
			                });
                            tableIn.reload();     
			            } else {
			                layer.msg(res.msg, {time: 1000, icon: 2});
			            }
			        });
                });
            } else {
                layer.msg(res.msg, {time: 1000, icon: 2});
            }
        });
    }
</script>
</body>
</html>